package com.significantfiles.snapshot.util.config;

import com.significantfiles.snapshot.engine.config.PersistenceParts;
import com.significantfiles.snapshot.engine.config.x.IllegalAnnotationValueException;

public class NumberOfFilePartsConfigUtil {

	public static int calcNumberOfFileParts(final Class<?> type)
			throws IllegalAnnotationValueException {

		if (type == null)
			throw new NullPointerException();

		final PersistenceParts parts = type
				.getAnnotation(PersistenceParts.class);

		final int rval = parts.number();
		
		if (rval < 1)
			throw new IllegalAnnotationValueException(PersistenceParts.class,
					"number[current: " + rval + "] must be bigger then 0.");

		return rval;
	}
}
